package Structural_design_pattern.Composite_Pattern.Example2;

import java.util.ArrayList;
import java.util.List;

public class Plate extends MyElement{
    private List<MyElement> myElementList = new ArrayList<MyElement>();

    @Override
    public void eat() {
        for (MyElement myElement : myElementList) {
            myElement.eat();
        }
    }

    public void add(MyElement myElement){
        myElementList.add(myElement);
    }

    public void remove(MyElement myElement){
        myElementList.remove(myElement);
    }

}
